package com.blockmeta.bbs.immodule.adapter;

import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blockmeta.bbs.baselibrary.base.adapter.BaseAdapter;
import com.blockmeta.bbs.baselibrary.utils.LoadPicUtil;
import com.blockmeta.bbs.immodule.R;
import com.blockmeta.bbs.immodule.net.pojo.KeyboardCoinAndPairPOJO;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * @author AirThor
 * @date 2020/3/30.
 * im键盘功能区 F10和行情
 */
public class KeyboardCoinAndPairAdapter extends BaseAdapter<KeyboardCoinAndPairPOJO, BaseViewHolder> {

    public KeyboardCoinAndPairAdapter(int layoutResId, @Nullable List<KeyboardCoinAndPairPOJO> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, KeyboardCoinAndPairPOJO item) {
        ImageView logo = helper.getView(R.id.iv_logo);
        TextView tvName = helper.getView(R.id.tv_name);
        if(TextUtils.isEmpty(item.name)){
            logo.setImageResource(R.drawable.icon_im_more);
            tvName.setVisibility(View.GONE);
        }else {
            LoadPicUtil.load(item.logo, logo, R.drawable.default_header);
            tvName.setVisibility(View.VISIBLE);
            tvName.setText(item.name.replace("_", "/").toUpperCase());
        }
    }
}
